﻿import request from '@/utils/requestBlog'

// 发送文章评论
export function sendComment(type,articleId,rootId,toCommentId,toCommentUserId,content,username,avatarUrl) {
    return request({
        url: '/comment/saveComment',
        method: 'post',
        headers: {
            isToken: true
          },
        data: {
            "articleId":articleId,
            "type":type,
            "rootId":rootId,
            "toCommentId":toCommentId,
            "toCommentUserId":toCommentUserId,
            "content":content,
            "createNick":username,
            "avatarUrl":avatarUrl
        }
    })
}

// 获取当前文章评论列表
export function getArticleComment(query) {
    return request({
        url: '/comment/commentList',
        method: 'get',
        headers: {
            isToken: false
        },
        params: query
    })
}

// 获取友链评论列表
export function getLinkComment(query) {
    return request({
        url: '/comment/linkCommentList',
        method: 'get',
        headers: {
            isToken: false
        },
        params: query
    })
}

// 置顶/取消置顶评论
export function setTop(id,label) {
    return request({
        url: '/comment/setCommentTop/' + id + '/' + label,
        method: 'put',
        headers: {
            isToken: true
        }
    })
}

// 管理员删除评论
export function deleteComment(id) {
    return request({
        url: '/comment/deleteComment/' + id,
        method: 'delete',
        headers: {
            isToken: true
        }
    })
}

// 管理员查询评论
export function allCommentList(query) {
    return request({
        url: '/comment/allCommentList',
        method: 'get',
        headers: {
            isToken: true
        },
        params: query
    })
}

// 用户删除评论
export function deleteMyComment(id) {
    return request({
        url: '/comment/deleteMyComment/' + id,
        method: 'delete',
        headers: {
            isToken: true
        }
    })
}

// 更新评论用户信息
export function updateComment(comment) {
    return request({
        url: '/comment/updateComment',
        method: 'put',
        headers: {
            isToken: true
        },
        data: comment
    })
}